﻿/**
 * File:   range_rule_widget.h
 * Author: 
 * Brief:  
 *
 * Copyright (c) 2024 - 2024 
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * License file for more details.
 *
 */

/**
 * History:
 * ================================================================
 * 2024-10-19  created
 *
 */


#ifndef TK_RANGE_RULE_WIDGET_H
#define TK_RANGE_RULE_WIDGET_H

#include "base/widget.h"

BEGIN_C_DECLS
/**
 * @class range_rule_widget_t
 * @parent widget_t
 * @annotation ["scriptable","design","widget"]
 * 
 * 在xml中使用"range\_rule\_widget"标签创建控件。如：
 *
 * ```xml
 * <!-- ui -->
 *   <range_rule_widget name="range_rule_widget" w="39" h="480" style:normal:border_color="#FFFFFF" style:normal:border_width="2" scale_nums="5" max_depth="5" style:normal:font_size="25" style:normal:text_color="#FFFFFF" is_horizonal="false"/>
 * ```
 *
 * 可用通过style来设置控件的显示风格，如字体的大小和颜色等等。如：
 * 
 * ```xml
 * <!-- style -->
 * <range_rule_widget>
 *   <style name="default" font_size="32">
 *     <normal text_color="black" />
 *   </style>
 * </range_rule_widget>
 * ```
 */
typedef struct _range_rule_widget_t {
  widget_t widget;

  /**
   * @property {int} max_depth
   * @annotation ["set_prop","get_prop","readable","persitent","design","scriptable"]
   * 最大深度
   */
  int max_depth;

  /**
   * @property {int} scale_nums
   * @annotation ["set_prop","get_prop","readable","persitent","design","scriptable"]
   * 刻度数
   */
  int scale_nums;

  /**
   * @property {int} offset
   * @annotation ["set_prop","get_prop","readable","persitent","design","scriptable"]
   * 刻度偏移
   */
  int offset;

  /**
   * @property {bool_t} is_horizonal
   * @annotation ["set_prop","get_prop","readable","persitent","design","scriptable"]
   * 是否垂直
   * 
   */
  bool_t is_horizonal;

  /**
   * @property {bool_t} is_num_reverse
   * @annotation ["set_prop","get_prop","readable","persitent","design","scriptable"]
   * 数字是否倒过来渲染，用于侧扫
   * 
   */
  bool_t is_num_reverse;
} range_rule_widget_t;

#define WIDGET_PROP_MAX_DEPTH "max_depth"
#define WIDGET_PROP_SCALE_NUMS "scale_nums"
#define WIDGET_PROP_OFFSET "offset"
#define WIDGET_PROP_IS_HORIZIONAL "is_horizonal"
#define WIDGET_PROP_IS_NUM_REVERSE "is_num_reverse" 

/**
 * @method range_rule_widget_create
 * @annotation ["constructor", "scriptable"]
 * 创建range_rule_widget对象
 * @param {widget_t*} parent 父控件
 * @param {xy_t} x x坐标
 * @param {xy_t} y y坐标
 * @param {wh_t} w 宽度
 * @param {wh_t} h 高度
 *
 * @return {widget_t*} range_rule_widget对象。
 */
widget_t* range_rule_widget_create(widget_t* parent, xy_t x, xy_t y, wh_t w, wh_t h);

/**
 * @method range_rule_widget_cast
 * 转换为range_rule_widget对象(供脚本语言使用)。
 * @annotation ["cast", "scriptable"]
 * @param {widget_t*} widget range_rule_widget对象。
 *
 * @return {widget_t*} range_rule_widget对象。
 */
widget_t* range_rule_widget_cast(widget_t* widget);





#define WIDGET_TYPE_RANGE_RULE_WIDGET "range_rule_widget"

#define RANGE_RULE_WIDGET(widget) ((range_rule_widget_t*)(range_rule_widget_cast(WIDGET(widget))))

/*public for subclass and runtime type check*/
TK_EXTERN_VTABLE(range_rule_widget);

END_C_DECLS

#endif /*TK_RANGE_RULE_WIDGET_H*/
